//
//  AddCell.m
//  SYPerfectDemo
//
//  Created by Lssyyy on 2018/9/6.
//  Copyright © 2018年 Lssyyy. All rights reserved.
//

#import "AddCell.h"


@implementation AddCell{
    UILabel *_contentLb;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.backgroundColor = [UIColor purpleColor];
        [self addUI];
    }
    return self;
}

- (void)addUI{
    _contentLb = [UILabel new];
    _contentLb.text = @"测试测试";
    _contentLb.textColor = [UIColor blackColor];
    
    [self.contentView addSubview:_contentLb];
    _contentLb.sd_layout
    .leftSpaceToView(self.contentView, 0)
    .topSpaceToView(self.contentView, 0)
    .widthIs(100)
    .autoHeightRatio(0);
    
    UIButton *btn = [UIButton buttonWithType:0];
    [btn setTitle:@"+" forState:0];
    [btn addTarget:self action:@selector(btnMethod) forControlEvents:UIControlEventTouchUpInside];
    [btn setBackgroundColor:[UIColor blackColor]];
    [self.contentView addSubview:btn];
    btn.sd_layout
    .rightEqualToView(self.contentView)
    .centerYEqualToView(_contentLb)
    .heightIs(20)
    .widthIs(40);
    

    [self setupAutoHeightWithBottomView:_contentLb bottomMargin:0];
    
    
}

- (void)btnMethod{
    UIView *redView = [UIView new];
    redView.backgroundColor = [UIColor redColor];
    [self.contentView addSubview:redView];
    redView.sd_layout
    .leftEqualToView(self.contentView)
    .widthIs(100)
    .heightIs(100)
    .topSpaceToView(_contentLb, 10);
    [self setupAutoHeightWithBottomView:redView bottomMargin:0];
    [self updateLayoutWithCellContentView:self.contentView];
    [self.contentView layoutSubviews];

}

@end
